package com.fireXXX.job.analysis.crawler;

import com.fireXXX.job.analysis.crawler.boss.constant.CityTypeEnum;
import com.fireXXX.job.analysis.crawler.boss.constant.EmployeeNumberTypeEnum;
import com.fireXXX.job.analysis.crawler.boss.constant.IndustryTypeEnum;
import com.fireXXX.job.analysis.crawler.boss.constant.PublicStepTypeEnum;
import com.fireXXX.job.analysis.crawler.common.*;
import com.fireXXX.job.analysis.crawler.service.IntegrationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

@SpringBootApplication(scanBasePackages = "com.fireXXX.job.analysis")
@EntityScan(basePackageClasses = {Starter.class, Jsr310JpaConverters.class}, basePackages = {"com.fireXXX.job.analysis"})
@EnableJpaAuditing
@EnableJpaRepositories(basePackages = {"com.fireXXX.job.analysis"})
public class Starter {

    @Autowired
    private CrawlerThreadPool crawlerThreadPool;

    @Autowired
    private IntegrationService integrationService;

    @EventListener(value = ApplicationReadyEvent.class)
    public void init() {
        crawlerThreadPool.start();

        integrationService.runCompanyTask();
    }

    public static void main(String[] args) {
        SpringApplicationBuilder builder = new SpringApplicationBuilder(Starter.class);
        builder.headless(false).run(args);
    }

}
